package main

import (
	"fmt"
	"strconv"
	"time"
)

func main() {
	ch := make(chan int, 3)
	for i := 1; i <= 10; i++ {
		fmt.Println("main(" + strconv.Itoa(i) + "): Hello, World.")
		time.Sleep(1 * time.Second)
	}
	go gotest1(ch)
	ch <- 1
	go gotest2(ch)
	ch <- 2
}

func gotest1(ch chan int) {
	for i := 1; i <= 10; i++ {
		fmt.Println("test1(" + strconv.Itoa(i) + "): Hello, Goroutine.")
		time.Sleep(2 * time.Second)
	}
	<-ch
}

func gotest2(ch chan int) {
	for i := 1; i <= 10; i++ {
		fmt.Println("test2(" + strconv.Itoa(i) + "): Hello, Goroutine.")
		time.Sleep(2 * time.Second)
	}
	<-ch
}
